/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ControlEscolar.Services;


import com.ControlEscolar.Beans.Professor;
import com.ControlEscolar.DAOs.DAOException;
import com.ControlEscolar.DAOs.ProfessorDAO;
import com.ControlEscolar.Exceptions.ServiceExp;
import com.ControlEscolar.Validations.ValidationProfessor;
import java.util.ArrayList;



/**
 *
 * @author Rodna Marrufo
 */
public class ProfessorService {
    ValidationProfessor validationProfessor = new ValidationProfessor();
    ProfessorDAO professorDAO=new ProfessorDAO();

    public void createProfessor(Professor professor) throws ServiceExp{
        try {
            if (validationProfessor.isExistProfessor(professor.getProfessor_Name(), professor.getProfessor_Tel())) {
                throw new ServiceExp();
            } else {
                professorDAO.add(professor);
                           }
        } catch (DAOException ex) {
            throw new ServiceExp();
        }
    }

    public void updateProfessor(Professor professor) throws ServiceExp{
        try {
            professorDAO.update(professor);
        } catch (DAOException ex) {
            throw new ServiceExp();
        }

    }

    public Professor getProfessor(int ID_Professor) throws ServiceExp {
        try {
            return professorDAO.queryByID(ID_Professor);
        } catch (DAOException ex) {
           throw new ServiceExp();
        }
    }

    public ArrayList<Professor> getProfessorList() throws ServiceExp {
        try {
            return professorDAO.query();
        } catch (DAOException ex) {
           throw new ServiceExp();
        }
    }
}
